<?php

/**
 * This is the model class for table "cs_tc_surrendinfo".
 *
 * The followings are the available columns in table 'cs_tc_surrendinfo':
 * @property integer $id
 * @property integer $surrendpolicy_id
 * @property string $CWaterNo
 * @property string $PolicyNum
 * @property string $RetCode
 * @property string $ReturnMsg
 * @property string $Policy_status
 * @property integer $RealDate
 * @property string $in_company
 * @property integer $create_time
 */
class Db2CsSurrendinfo extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'cs_tc_surrendinfo';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('surrendpolicy_id', 'required'),
			array('surrendpolicy_id, RealDate, create_time', 'numerical', 'integerOnly'=>true),
			array('CWaterNo, PolicyNum, ReturnMsg, Policy_status, in_company', 'length', 'max'=>45),
			array('RetCode', 'length', 'max'=>10),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('id, surrendpolicy_id, CWaterNo, PolicyNum, RetCode, ReturnMsg, Policy_status, RealDate, in_company, create_time', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'surrendpolicy_id' => 'Surrendpolicy',
			'CWaterNo' => 'Cwater No',
			'PolicyNum' => 'Policy Num',
			'RetCode' => 'Ret Code',
			'ReturnMsg' => 'Return Msg',
			'Policy_status' => 'Policy Status',
			'RealDate' => 'Real Date',
			'in_company' => 'In Company',
			'create_time' => 'Create Time',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('surrendpolicy_id',$this->surrendpolicy_id);
		$criteria->compare('CWaterNo',$this->CWaterNo,true);
		$criteria->compare('PolicyNum',$this->PolicyNum,true);
		$criteria->compare('RetCode',$this->RetCode,true);
		$criteria->compare('ReturnMsg',$this->ReturnMsg,true);
		$criteria->compare('Policy_status',$this->Policy_status,true);
		$criteria->compare('RealDate',$this->RealDate);
		$criteria->compare('in_company',$this->in_company,true);
		$criteria->compare('create_time',$this->create_time);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * @return CDbConnection the database connection used for this class
	 */
	public function getDbConnection()
	{
		return Yii::app()->db2;
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return Db2CsSurrendinfo the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
